<%--
  Created by IntelliJ IDEA.
  User: kingshion
  Date: 2020/6/3
  Time: 10:55
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>试题展示</title>
    <link rel="stylesheet" href="../layui/css/layui.css">
    <script src="../layui/layui.js"></script>
    <title>题目管理</title>
</head>
<body>

<label style="color: rgb(158, 158, 158);">从下面的列表里选取试卷</label>
<div class="demoTable">
    搜索考试类别：
    <div class="layui-inline">
        <input class="layui-input" name="id" id="demoReload" autocomplete="off" lay-filter="demoReload">
    </div>
    <button class="layui-btn" data-type="reload">搜索</button>
</div>


<table class="layui-hide" id="examShows" lay-filter="user"></table>



<script src="//res.layui.com/layui/dist/layui.js" charset="utf-8"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use('table', function () {
        var table = layui.table;

        //方法级渲染
        table.render({
            elem: '#examShows',
            url: '/OnlineExam/admin/exampaper?m=showExams',
            cols: [[
                {type: 'checkbox', fixed: 'left', width: '3%'},
                {field: 'exampaper_id', title: '试卷ID', fixed: 'center', sort: true, width: '7%'},
                {field: 'exampaper_name', fixed: 'center', title: '试卷名称', width: '20%'},
                {field: 'course_name', fixed: 'center', title: '试卷类别', width: '10%'},
                {field: 'user_id', fixed: 'center', title: '创建人', width: '7%'},
                {field: 'create_time', fixed: 'center', title: '创建时间', width: '10%'},
                {field: 'exampaper_desc', fixed: 'center', title: '试卷描述', width: '28%'},
                {fixed: 'center', title: '操作', toolbar: '#barDemo', width: '15%'}
            ]],
            id: 'testReload',
            page: true
        });

        var $ = layui.$, active = {
            reload: function () {
                var demoReload = $('#demoReload');

                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        key: {
                            course_name: demoReload.val()
                        }
                    }
                }, 'data');
            }
        };

        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

    });
</script>

</body>
</html>
